home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).zip / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).adf / mand2000 / arexx / IterMovie.mnd2 < prev    next >
Text File  |  1993-11-09  |  10KB  |  297 lines

  1. /* This script is supplied with the Mand2000 demo and release */
  2. /* versions and may be freely distributed. */
  3. /* Copyright 1993 Cygnus Software. */
  4.  
  5. /* An ARexx programming for creating iteration movies. */
  6.  
  7. /*
  8.     When Mand2000 calculates a picture, it stores the iteration counts
  9. for each pixel, memory permitting.  This means that if you calculate a
  10. movie at an iteration count of, say, 1000, Mand2000 can redisplay that
  11. picture the way it would look with an iteration count of any number under
  12. 1000, without doing any recalculating.  This script makes use of that
  13. features to allow fast and easy creation of iteration movies.  These
  14. animations can look quite impressive, as fractal fingers gradually take
  15. over the black screen.
  16.  
  17.     This script asks the user for some input to help it create a
  18. reasonable movie.  The first thing it asks for is the final iteration
  19. count.  After that it asks the user for the starting iteration count.  For
  20. best results let the picture completely calculate at the final iteration
  21. count before you set it to the starting iteration count.  Typically you
  22. want the final iteration count to have pretty much all of the colour that
  23. is going to appear be there.  Typically you want the start iteration count
  24. to make the picture black.
  25.  
  26.     When you've set these values the script tells Mand2000 to keep
  27. redrawing the picture starting at the low iteration count and working up.
  28. The successive frames are saved to the Ram Disk as ITERFRAME10001 and
  29. upwards.  The base frame name can be changed by editing this script.  If
  30. the iterations are changing too quickly, or too slowly, you can adjust the
  31. IterInc, SpeedUpPoint and IncDivisor values to tune your movie.
  32.     IterInc is the initial amount by which the iterations are
  33. incremented after each frame.
  34.     SpeedUpPoint is the iteration count at which the iteration level
  35. starts changing faster.
  36.     IncDivisor adjusts how quickly the increase speeds up.  Smaller
  37. numbers make it increase faster.
  38.  
  39.     Because Mand2000 is live the whole time this movie is being
  40. generated, you can also adjust things on the fly.  If the final stages are
  41. obviously taking too long you can use the max iterations requester to
  42. manually increase the iterations, thus cutting out some of the unecessary
  43. frames.
  44.  
  45.     The resulting sequence of frames can be easily loaded into DPaint
  46. or any other program for creating animations.
  47.  
  48.     This script will, optionally, use ADPro to create an animation file out
  49. of  the  individual  frames  as  they  are  generated.  This saves time and
  50. reduces  the  user  intervention  required to create a movie.  Also, if the
  51. script  were  modified  so  that the frames were deleted off of the disk as
  52. soon  as  they had been put into the Anim, the disk space required would be
  53. reduced.
  54.     */
  55.  
  56. portname = address()    /* Retrieve the current port name. */
  57. /* If the portname does not start with MAND2000 then this script must */
  58. /* have been run with rx, rather than from Mand2000.  Therefore we */
  59. /* need to set the port name.  We do not always set the port name */
  60. /* because it is better to let Mand2000 set it for us, so that */
  61. /* this script can be used with windows other than the one with */
  62. /* port name MAND2000.1. */
  63. if (left(portname, 8) ~= "MAND2000") THEN
  64.     address 'MAND2000.1'
  65.  
  66. options results
  67.  
  68. /* Settings for I like this one. */
  69. /*IterInc = 2*/
  70. /*SpeedUpPoint = 115*/
  71. /*IncDivisor = 6*/
  72. /*SpeedUpPoint2 = 115*/
  73. /*IncDivisor2 = 6*/
  74.  
  75. /* Settings for Nautilus. */
  76. IterInc = 2
  77. SpeedUpPoint = 220
  78. IncDivisor = 17
  79. SpeedUpPoint2 = 700
  80. IncDivisor2 = 5
  81.  
  82. /* Settings for Needle. */
  83. /*IterInc = 2*/
  84. /*SpeedUpPoint = 315*/
  85. /*IncDivisor = 10*/
  86. /*SpeedUpPoint2 = 475*/
  87. /*IncDivisor2 = 6*/
  88.  
  89. /* Settings for all the way out. */
  90. /*IterInc = 2*/
  91. /*SpeedUpPoint = 75*/
  92. /*IncDivisor = 9*/
  93. /*SpeedUpPoint2 = 128*/
  94. /*IncDivisor2 = 4*/
  95.  
  96. /* Settings for spiral galaxy. */
  97. /*IterInc = 2*/
  98. /*SpeedUpPoint = 90*/
  99. /*IncDivisor = 9*/
  100. /*SpeedUpPoint2 = 90*/
  101. /*IncDivisor2 = 9*/
  102.  
  103. /* Settings for double spiral. */
  104. /*IterInc = 25*/
  105. /*SpeedUpPoint = 3500*/
  106. /*IncDivisor = 6*/
  107. /*SpeedUpPoint2 = 3500*/
  108. /*IncDivisor2 = 6*/
  109.  
  110.  
  111. /* Parse out the command option.  This script is called when the */
  112. /* user wants a movie started, when the user wants a movie */
  113. /* aborted and whenever one of the pictures in the sequence is done.  */
  114.  
  115. parse arg command
  116.  
  117. command = upper(command)    /* Make sure the command is in upper case. */
  118.  
  119. if (command = START) then
  120.     CALL StartIterMovie()
  121. else if (command = STOP) then
  122.     CALL StopIterMovie()
  123. else
  124.     CALL ContinueIterMovie()
  125.  
  126. Exit
  127.  
  128.  
  129.  
  130. StartIterMovie:
  131.     DECPAUSE        /* Allow Mand2000 to resume calculating while this script executes. */
  132.     REQUESTER MAXITERS    /* See whether the maxiters requester is up already. */
  133.     maxitersstate = RESULT
  134.     REQUESTER MAXITERS ON    /* Force it to be up regardless. */
  135.     REQUESTNOTIFY "This ARexx script makes an|animation by having the maximum|iterations of a fractal picture|increase from frame to frame.|Select `Continue' on this|requester when you have set max|iters to the desired finish value.|You should set it to the smallest|value that causes all, or almost|all, coloured pixels to be filled|in, then wait for the picture to|finish calculating before|selecting `Continue'."
  136.     GETATTR stem PROJ
  137.     CALL SETCLIP("Mand2000IterEnd", PROJ.MAXITERS)
  138.  
  139.     /* Try to make sure that the high iteration picture is finished before continuing. */
  140.     /* This allows Mand2000 to create the animation MUCH faster.  If you wanted to you */
  141.     /* could change the script so that it loops until the picture is done. */
  142.     if (PROJ.DONE ~= 1) THEN
  143.         REQUESTNOTIFY "Click `Continue' when this|picture finishes calculating."
  144.  
  145.     REQUESTER MAXITERS ON    /* Force it to be up regardless. */
  146.     REQUESTNOTIFY "Now click `Continue' when you have|set max iters to the desired start|value for the animation.|Typically you will want to set it|to the highest value where the|screen is all black."
  147.  
  148.     /* Turn the maxiters requester off, if that's how it started. */
  149.     if (maxitersstate = 0) THEN
  150.         REQUESTER MAXITERS OFF
  151.  
  152.     /* Put a command in the user menu for stopping the movie creation. */
  153.     menu '"------------------------"'
  154.     menu '"Stop Iter Movie"' itermovie stop
  155.  
  156.     INCPAUSE        /* Stop calculations again. */
  157.     CALL SETCLIP("Mand2000FrameNum", 10001)
  158.     /* Tell Mand2000 to call this script whenever a pictures finishes calculating. */
  159.     EVENTACTION PICTUREDONE IterMovie
  160.     GETATTR stem PROJ
  161.     /* Assume that ADPro is not wanted. */
  162.     CALL SETCLIP("ITERTOADPRONAME")
  163.     /* Then ask if it is. */
  164.     REQUESTRESPONSE "Would you like the frames|written to an anim file|by ADPro?"
  165.     if (RC = 0) THEN DO
  166.         REQUESTSAVEFILE 'title="Iter anim file name."' 'path="RAM:"' 'file="IterAnim"'
  167.         CALL SETCLIP("ITERTOADPRONAME", result)
  168.         END
  169.     if (PROJ.DONE = 1) THEN
  170.         CALL ContinueIterMovie()    /* If the current frame is already finished, save it and go to  */
  171.                     /* the next one.  Otherwise wait for this routine to be called   */
  172.                     /* again when the picture does finish calculating. */
  173.     RETURN 0
  174.  
  175.  
  176.  
  177. StopIterMovie:
  178.     /* Tell Mand2000 not to call this script any more. */
  179.     EVENTACTION PICTUREDONE
  180.     /* Remove the `stop iter movie' menu. */
  181.     CLEARNMENUS 2
  182.     CALL SETCLIP("Mand2000Iters")
  183.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  184.     if (FRAMENUM = "") THEN
  185.         EXIT
  186.     CALL SETCLIP("Mand2000FrameNum")
  187.     AnimName = GETCLIP("ITERTOADPRONAME")
  188.     if (AnimName ~= "") THEN DO
  189.         if ~show('p',"ADPro") THEN
  190.             EXIT
  191.         /* Start sending commands to ADPro. */
  192.         ADDRESS "ADPro"
  193.         /* Specify that we want to save an animation file. */
  194.         SFORMAT Anim
  195.         /* Save as anim frame. */
  196.         SAVE AnimName IMAGE WRAPUP BYTE FASTER
  197.         Why = ADPRO_RESULT
  198.         if (RC ~= 0) THEN DO
  199.             REQUESTNOTIFY "Error in wrap up.|Aborting animation."
  200.             CALL StopIterMovie()
  201.             EXIT
  202.             END
  203.         /* Resume sending commands to Mand2000. */
  204.         ADDRESS
  205.         if (FRAMENUM = 10001) THEN
  206.             REQUESTNOTIFY "Zero frames created."
  207.         else if (FRAMENUM = 10002) THEN
  208.             REQUESTNOTIFY "One frame created."
  209.         else
  210.             REQUESTNOTIFY "Just created a "FRAMENUM - 10001" frame anim.|Use DPaint or View to play it."
  211.         EXIT
  212.         END
  213.     if (FRAMENUM = 10001) THEN
  214.         REQUESTNOTIFY "Zero frames created."
  215.     else if (FRAMENUM = 10002) THEN
  216.         REQUESTNOTIFY "One frame created."
  217.     else
  218.         REQUESTNOTIFY "Just created "FRAMENUM - 10001" iter frames.|Use ADPro or DPaint to make these|into an animation."
  219.     RETURN 0
  220.  
  221.  
  222.  
  223. ContinueIterMovie:
  224.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  225.     SAVEAS "NAME=RAM:ITERFRAME"FRAMENUM 1    /* Save the location and graphics (type 1) of the frame. */
  226.     if (RC ~= 0) THEN DO
  227.         REQUESTNOTIFY "Error in saving frame "FRAMENUM".|Aborting animation."
  228.         CALL StopIterMovie()
  229.         EXIT
  230.         END
  231.     AnimName = GETCLIP("ITERTOADPRONAME")
  232.     if (AnimName ~= "") THEN DO
  233.         if ~show('p',"ADPro") THEN DO
  234.             REQUESTNOTIFY "Error - ADPro is not running.|Aborting animation."
  235.             CALL StopIterMovie()
  236.             EXIT
  237.             END
  238.         /* Start sending commands to ADPro. */
  239.         ADDRESS "ADPro"
  240.         /* Specify that we want to load an IFF file. */
  241.         LFORMAT IFF
  242.         /* Load the last generated frame, don't bother converting to 24 bit. */
  243.         Load "RAM:ITERFRAME"FRAMENUM nopad
  244.         if (RC = 10) THEN DO
  245.             REQUESTNOTIFY "Error in loading to ADPro.|Aborting animation."
  246.             CALL StopIterMovie()
  247.             EXIT
  248.             END
  249.         /* Specify that we want to save an animation file. */
  250.         SFORMAT Anim
  251.         /* Save as anim frame. */
  252.         SAVE AnimName IMAGE APPEND BYTE FASTER
  253.         Why = ADPRO_RESULT
  254.         if (RC ~= 0) THEN DO
  255.             REQUESTNOTIFY "Error in anim save.|Aborting animation."
  256.             CALL StopIterMovie()
  257.             EXIT
  258.             END
  259.         /* Resume sending commands to Mand2000. */
  260.         ADDRESS
  261.         /* At this point the IFF file could be deleted from the RAM disk. */
  262.         END
  263.     FRAMENUM = FRAMENUM + 1
  264.     CALL SETCLIP("Mand2000FrameNum", FRAMENUM)
  265.  
  266.     GETATTR stem PROJ
  267.     ITERNUM = PROJ.MAXITERS
  268.     ENDITERNUM = GETCLIP("Mand2000IterEnd")
  269.     if (ITERNUM >= ENDITERNUM) THEN DO
  270.         CALL StopIterMovie()
  271.         EXIT
  272.         END
  273.  
  274. /* Custom code for a particular picture. */
  275. /*    ITERNUM = ITERNUM + 1*/
  276. /**/
  277. /*    if (ITERNUM > 25) THEN*/
  278. /*        ITERNUM = ITERNUM + 1*/
  279. /**/
  280. /*    if (ITERNUM > 32) THEN*/
  281. /*        ITERNUM = ITERNUM + (ITERNUM - 26) % 4*/
  282. /**/
  283. /*    if (ITERNUM > 100) THEN*/
  284. /*        ITERNUM = ITERNUM + (ITERNUM - 26) % 6*/
  285.  
  286.     ITERNUM = ITERNUM + IterInc
  287.     if (ITERNUM > SpeedUpPoint2) THEN
  288.         ITERNUM = ITERNUM + 2 + (ITERNUM - SpeedUpPoint) % IncDivisor2
  289.     else if (ITERNUM > SpeedUpPoint) THEN
  290.         ITERNUM = ITERNUM + (ITERNUM - SpeedUpPoint) % IncDivisor
  291.  
  292.     if (ITERNUM >= ENDITERNUM) THEN
  293.         ITERNUM = ENDITERNUM
  294.  
  295.     MAXITERS ITERNUM
  296.     RETURN 0
  297.